import SinaPy
import io
import sys
import time
import threading
if __name__ == "__main__":
    #sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gbk')

    sinaTick = SinaPy.SinaTick("localhost", ["idcodes.txt", "shcodes.txt", "szcodes.txt"])
    sinaTick.readAllCodes()
    while True:
        start = time.time()
        ready, frame = sinaTick.downloadTicks()
        end = time.time()
        if ready:
            print(frame)
            print("time spent {0}", end - start)
            time.sleep(2)
